package com.tencent.cloud.iov.util.rx.proxy;

import android.support.annotation.CallSuper;

import com.tencent.cloud.iov.util.rx.SimpleObserver;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * 代理观察者
 *
 * @author showxiao
 * @date 2018/5/14
 */

public class ProxyObserver<T> extends SimpleObserver<T> {

    private final Observer<T> mActual;

    public ProxyObserver(Observer<T> actual) {
        mActual = actual;
    }

    @CallSuper
    @Override
    public void onSubscribe(Disposable d) {
        super.onSubscribe(d);
        mActual.onSubscribe(d);
    }

    @CallSuper
    @Override
    public void onNext(T t) {
        super.onNext(t);
        mActual.onNext(t);
    }

    @CallSuper
    @Override
    public void onError(Throwable e) {
        super.onError(e);
        mActual.onError(e);
    }

    @CallSuper
    @Override
    public void onComplete() {
        super.onComplete();
        mActual.onComplete();
    }
}
